// 根据角色动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";

export default defineFakeRoute([
  {
    url: "/login",
    method: "post",
    response: ({ body }) => {
      console.log(body);

      // if (body.username === "admin") {
      //   return {
      //     success: true,
      //     data: {
      //       avatar: "https://avatars.githubusercontent.com/u/44761321",
      //       username: "admin",
      //       nickname: "小铭",
      //       // 一个用户可能有多个角色
      //       roles: ["admin"],
      //       accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
      //       refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
      //       expires: "2030/10/30 00:00:00",
      //       clientId: "e5cd7e4891bf95d1d19206ce24a7b32e"
      //     }
      //   };
      // } else {
      //   return {
      //     success: true,
      //     data: {
      //       avatar: "https://avatars.githubusercontent.com/u/52823142",
      //       username: "common",
      //       nickname: "小林",
      //       roles: ["common"],
      //       accessToken: "eyJhbGciOiJIUzUxMiJ9.common",
      //       refreshToken: "eyJhbGciOiJIUzUxMiJ9.commonRefresh",
      //       expires: "2030/10/30 00:00:00"
      //     }
      //   };
      // }
      return {
        success: true,
        data: {
          avatar: "",
          username: "admin",
          nickname: "admin",
          // 一个用户可能有多个角色
          // roles: ["admin"],
          accessToken: "eyJhbGciOiJIUzUxMiJ9.admin",
          refreshToken: "eyJhbGciOiJIUzUxMiJ9.adminRefresh",
          expires: "2030/10/30 00:00:00",
          clientId: "e5cd7e4891bf95d1d19206ce24a7b32e"
        }
      };
    }
  }
]);
